#include<algorithm>
#include<iostream>
using namespace std;
const int N=100005;
int n,m,l,s,d[N],v[N],a[N],p[N];
int cnt,top,lp[N],rp[N];pair<int,int> stk[N];
void work()
{
    cin>>n>>m>>l>>s,top=cnt=0;
    for(int i=1;i<=n;i++)
    {
        cin>>d[i]>>v[i]>>a[i];
        if(a[i]<=0 && v[i]<=s)lp[i]=rp[i]=-1;
        if(a[i]<0 && v[i]>s)
        {
            if(s*s-v[i]*v[i]+2*d[i]*a[i]<2*l*a[i])lp[i]=d[i],rp[i]=l;
            else lp[i]=d[i],rp[i]=d[i]+(v[i]*v[i]-s*s-1)/(-2*a[i]);
        }
        if(a[i]>=0 && v[i]>s)lp[i]=d[i],rp[i]=l;
        if(a[i]>0 && v[i]<=s)
        {
            if(s*s-v[i]*v[i]+2*d[i]*a[i]>=2*l*a[i])lp[i]=rp[i]=-1;
            else lp[i]=d[i]+(s*s-v[i]*v[i])/(2*a[i])+1,rp[i]=l;
        }
    }
    for(int i=1;i<=m;i++)cin>>p[i];
    for(int i=1;i<=n;i++)
        if(lp[i]<=rp[i] && lp[i]!=-1)
        {
            int _x=lower_bound(p+1,p+m+1,lp[i])-p;
            int _y=upper_bound(p+1,p+m+1,rp[i])-p-1;
            if(_x<=_y)stk[++top]=make_pair(_x,_y);
        }
    cout<<top<<' ';
    sort(stk+1,stk+top+1);
    for(int i=1,rm=-114;i<=top;i++)
    {
        if(rm<stk[i].first)rm=2*N,cnt++;
        rm=min(rm,stk[i].second);
    }
    cout<<m-cnt<<endl;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;cin>>t;while(t--)work();
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 -2
6 4 -4
2 5 8 9 15
-----
-1 -1
12 15
2 15
5 3
6 0
9 15
2 1
*/